package com.itheima.controller;

import com.itheima.domain.SmsHomeRecommendSubject;
import com.itheima.manager.SmsHomeRecommendSubjectManager;
import com.itheima.util.R;
import com.itheima.vo.PageBeanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class SmsHomeRecommendSubjectController {

    @Autowired
    SmsHomeRecommendSubjectManager smsHomeRecommendSubjectManager;

    /**
     * 营销-专题推荐-分页条件查询
     * @param pageNum
     * @param pageSize
     * @param subjectName
     * @param recommendStatus
     * @return
     */
    @GetMapping("/home/recommendSubject/list")
    public R findRecommendSubjectByPage(Integer pageNum,Integer pageSize,String subjectName,Integer recommendStatus){
        PageBeanVo pageBeanVo = smsHomeRecommendSubjectManager.findRecommendSubjectByPage(pageNum, pageSize, subjectName, recommendStatus);
        return R.success(pageBeanVo);
    }

    /**
     * 营销-专题推荐-添加专题
     * @param smsHomeRecommendSubjectList
     * @return
     */
    @PostMapping("/home/recommendSubject/create")
    public R addSubject(@RequestBody List<SmsHomeRecommendSubject> smsHomeRecommendSubjectList){
        return smsHomeRecommendSubjectManager.addSubject(smsHomeRecommendSubjectList);
    }

    /**
     * 营销-专题推荐-单个|多个修改推荐状态
     * @param ids
     * @param recommendStatus
     * @return
     */
    @PostMapping("/home/recommendSubject/update/recommendStatus")
    public R update(@RequestParam("ids") List<Long> ids, @RequestParam Integer recommendStatus){
        return smsHomeRecommendSubjectManager.update(ids,recommendStatus);
    }

    /**
     * 营销-专题推荐-单个|多个删除
     * @param ids
     * @return
     */
    @PostMapping("/home/recommendSubject/delete")
    public R delete(@RequestParam("ids") List<Long> ids){
        return smsHomeRecommendSubjectManager.delete(ids);
    }

    /**
     * 营销-专题推荐-修改排序
     * @param id
     * @param sort
     * @return
     */
    @PostMapping("/home/recommendSubject/update/sort/{id}")
    public R updateSort(@PathVariable Long id, @RequestParam Integer sort){
        return smsHomeRecommendSubjectManager.updateSort(id,sort);
    }
}
